<template>
  <!-- 往期留言 -->
  <div class="comment-list">
    <div class="item" v-for="(item, index) in commentData" :key="index">
      <div class="avatar">{{item.name[0]}}</div> 
      <div class="comment-main">
        <p class="name">{{item.name}}<a class="email" :href="'mailto:' + item.email">{{item.email}}</a></p> 
        <p class="time">{{item.createTime | FDateTime}}</p> 
        <div>{{item.content}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    commentData: {
      type: Array,
      required: true
    }
  }
}
</script>

<style lang="scss">
  $red : #FF0000;
  $orange : #FFA500;
  $green : #008000;
  $blue : #0000FF;
  $purple : #800080;
  $bgcolorlist: $red $orange $green $blue $purple $red $orange $green $blue $purple;
  @for $i from 1 to length($bgcolorlist)+1 {
    .comment-list .item:nth-child(#{$i}) .avatar{
      background-color: nth($bgcolorlist,$i);
    }
  }
  .comment-list {
    padding: 30px 0;
    .item {
      padding: 10px 0;
      font-size: 14px;
      color: #666;
      display: flex;
      align-items: center;
      .avatar {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        text-align: center;
        line-height: 40px;
        border-radius: 100%;
        margin: 0 10px 10px 0;
        color: #fff;
        font-weight: bold;
        font-size: 18px;
      }
      .comment-main {
        flex: 1;
        .name { 
          padding: 15px 0 0 0;
          .email {
            text-decoration: underline;
            margin-left: 20px;
            font-size: 12px;
            color: #666;
          }
        }
        .time {
          color: #999;
          font-size: 12px;
          padding: 5px 0 10px 0;
        }
      }
    }
  }
</style>
